import { pget, ppostJson, post } from '@/utils/req'
import { modalApi } from '@/utils/modalReq'

// 采购合同分页
export function getTableList(data: any) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-contract/contract/page`,
		data,
	)
}

// 采购合同分页
export function contractList(data: any) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-contract/contract/list`,
		data,
	)
}

// 采购合同不分页
export function getAllContractList(query: any) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-contract/contract/availableList`,
		query,
	)
}

// 新增采购合同
export function addContract(data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-contract/contract/save`,
		data,
	)
}
/** 采购合同保存 */
export function contractSaveTemporary(data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-contract/contract/saveTemporary`,
		data,
	);
}

// 修改采购合同
export function editContract(id: string, data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-contract/contract/update/${id}`,
		data,
	)
}

// 删除采购合同
export function deleteContract(data: { ids: string }) {
	return post(
		`${modalApi.purchase}/shopec-purchase-contract/contract/remove`,
		data,
	)
}

// 查看采购合同
export function viewContract(id: string) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-contract/contract/detail/${id}`,
	)
}

// 工作流接口
/** 流程新增 */
export function contractProcessAdd(data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-contract/contract/submitFlow`,
		data,
	)
}
// 采购计划审核
export function contractAuditFlow(data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-contract/contract/auditFlow`,
		data,
	)
}
// 作废采购计划后重新发起审核
export function contractRelaunchFlow(id: any, data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-contract/contract/relaunchFlow/${id}`,
		data,
	)
}
